﻿__author__ = 'guzhan.pc'
# coding:utf-8

from bs4 import BeautifulSoup

# 节目结构体
class AGShow:
    def __init__(self):	
        self.time = ''      # 节目开始的时间
        self.content=''  # 节目内容


# 获取当前html中所有的节目
# 返回结果结构：字典 eg {'月曜日'：[showlist], }
def getAGAllShowList(html_doc):
    soup = BeautifulSoup(html_doc)
    showDict = {}
    alltables = soup.find_all('table', id='timeline')
    for table in alltables:
        AGShowList = []
        weekday = table.find_all('th')[0].string
        for td in table.find_all('td'):
            show = AGShow()
            show.time = td.find('strong').string
            show.content = td.text.replace(show.time, '').strip()
            AGShowList.append(show)
        showDict.setdefault(weekday, AGShowList)
    return showDict